-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: deflake run_kubectl_apply_tests #93657
Conversation
test/cmd/apply.sh
Outdated
@@ -444,6 +444,9 @@ run_kubectl_server_side_apply_tests() { | |||
} | |||
__EOF__ | |||
|
|||
# Ensure the CRD has been created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the correct check... the CRD will always be created here
The issue is whether the API server has recognized and started serving the associated CR API yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liggitt Is it possible to do a wait on a Condition for a CRD? (e.g. kubectl wait --for=condition=Ready mygroup.example.com/myobj --timeout=30s
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to wait until kubectl observes the expected API available in discovery (kubectl api-resources
contains the new API)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seans3 you could wait for condition Established
, although I am not certain that guarantees that it is being served
kubernetes/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go
Line 279 in 2585d78
Established CustomResourceDefinitionConditionType = "Established" |
/test pull-kubernetes-conformance-kind-ipv6-parallel |
test/cmd/apply.sh
Outdated
break | ||
fi | ||
echo "${i}: Waiting for CR API to be available" | ||
sleep $((i-1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing something but why the changing sleep time? Is it intended to be a rudimentary backoff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no special reason, just following the existing practice
Lines 82 to 93 in c381615
for j in $(seq 1 "${tries}"); do | |
# shellcheck disable=SC2086 | |
# Disabling because "args" needs to allow for expansion here | |
res=$(eval kubectl get "${kube_flags[@]}" ${args} "${object}" -o go-template=\""${request}"\") | |
if [[ "${res}" =~ ^$expected$ ]]; then | |
echo -n "${green}" | |
echo "$(kube::test::get_caller 3): Successful get ${object} ${request}: ${res}" | |
echo -n "${reset}" | |
return 0 | |
fi | |
echo "Waiting for Get ${object} ${request} ${args}: expected: ${expected}, got: ${res}" | |
sleep $((j-1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could fix the sleep time if that is preferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knight42 I think it's okay, just wanted to know the motivation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is similar, used in other places, and is easier to read:
sleep $((i-1)) | |
sleep "${i}" |
Saw another flake on this last night. @liggitt could you give this another look? |
test/cmd/apply.sh
Outdated
# Ensure the API server has recognized and started serving the associated CR API | ||
local tries=5 | ||
for i in $(seq 1 $tries); do | ||
if kubectl "${kube_flags_with_token[@]}" api-resources --api-group 'mygroup.example.com' -oname | grep -q 'resources.mygroup.example.com'; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
piping to grep -q
breaks things, see #57805
test/cmd/apply.sh
Outdated
# Ensure the API server has recognized and started serving the associated CR API | ||
local tries=5 | ||
for i in $(seq 1 $tries); do | ||
local output=$(kubectl "${kube_flags_with_token[@]}" api-resources --api-group 'mygroup.example.com' -oname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local output=$(kubectl "${kube_flags_with_token[@]}" api-resources --api-group 'mygroup.example.com' -oname) | |
local output=$(kubectl "${kube_flags[@]}" api-resources --api-group mygroup.example.com -o name) |
/lgtm |
/milestone v1.19 test-only change addressing a flake clouding CI signal |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: knight42, liggitt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: knight42 <anonymousknight96@gmail.com>
Force push to address shellcheck errors: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/93657/pull-kubernetes-verify/1291016793187422209
|
/lgtm |
Signed-off-by: knight42 anonymousknight96@gmail.com
What type of PR is this?
/kind flake
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #93651
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: